﻿@{
    ViewBag.Title = "Announcement";
    Layout = "~/Views/Shared/Houyun.cshtml";
    
}


<div class="page-header clearfix">
    <h1 class="pull-left">网站公告管理</h1>
    <div class="pull-right">
        <!-- Button trigger modal -->
        <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#addmodal">
            新增公告
        </button>
    </div>

</div>

<!-- 添加模态框 -->
<div class="modal fade" id="addmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">

    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form data-widget-cid="widget-0" novalidate="novalidate" id="announcement-create-form" class="form-horizontal" method="post" action="/Group/announcementCreate">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">新增公告</h4>
                </div>
                <div class="modal-body">

                    <div class="row form-group">
                        <div class="col-md-2 control-label">
                            <label for="title">公告内容</label>
                        </div>
                        <div class="col-md-8 controls">
                            <input data-explain="" data-widget-cid="widget-2" id="title" name="BNAME" class="form-control" type="text">
                            <div class="help-block" style="display:none;"></div>
                        </div>
                    </div>

                    <div class="row form-group">
                        <div class="col-md-2 control-label">
                            <label for="url">内容链接</label>
                        </div>
                        <div class="col-md-8 controls">
                            <input data-explain="以&quot;http://&quot;或&quot;https://&quot;开头" data-widget-cid="widget-3" id="url" name="BSOURCE" class="form-control" type="text">
                            <p class="help-block">以"http://"或"https://"开头</p>
                        </div>
                    </div>
                    @*<div class="row form-group">
                        <div class="col-md-2 control-label">
                            <label for="startTime">发布时间</label>
                        </div>
                        <div class="col-md-8 controls" style="z-index:2000;">
                            <input data-explain="" data-widget-cid="widget-1" id="startTime" name="MSTARTTIMR" class="form-control" type="text">
                            <div class="help-block" style="display:none;"></div>
                        </div>
                    </div>*@
                    <div class="row form-group">
                        <div class="col-md-2 control-label">
                            <label for="endTime">结束时间</label>
                        </div>
                        <div class="col-md-8 controls" style="z-index:2000;">
                            <input data-explain="" data-widget-cid="widget-4" id="endTime" name="MFINISHTIME" class="form-control" type="text">
                            <div class="help-block" style="display:none;"></div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
<table id="announcement-table" class="table table-striped">
    <thead>
        <tr>
            <th width="28%">公告信息</th>
            <th>发布时间</th>
            <th>结束时间</th>
            <th>状态</th>
            <th>发布人</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in ViewBag.GetAll as List<LeEdu.MODEL.Bulletin>)
        {

            <tr>
                <td><a href="@item.BSOURCE" target="_content">@item.BNAME</a></td>
                <td>@item.MSTARTTIMR</td>
                <td>@item.MFINISHTIME</td>
                <td>
                    @(@item.MSTARTTIMR > DateTime.Now ? "即将开始" : @item.MFINISHTIME < DateTime.Now ? "已结束" : "显示中")
                </td>
                <td>@item.Users.Uname</td>
                <td>
                    <div class="btn-group">
                        <a href="/Group/announcementEdit/@item.BulletinID" class="btn btn-default btn-sm" data-toggle="modal" data-target="#editmodal">编辑</a>
                        <a href="/Group/announcementDel/@item.BulletinID" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/Group/announcementDel/@item.BulletinID" @*data-url="/Group/announcementDel/@item.BulletinID"*@ onclick="return confirm('确定删除此公告吗?')" class="delete-btn"><span class="glyphicon glyphicon-trash"></span> 删除</a></li>

                        </ul>
                    </div>
                </td>
            </tr>
        }
    </tbody>
</table>
<!--模态框----编辑公告-->

<div class="modal fade" id="editmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content"></div>
    </div>
</div>
<!--模态框传值问题（加载一次模态框 清楚一下以前的数据  不然数据不变）-->
<script>
    $("#editmodal").on("hidden.bs.modal", function () {
        $(this).removeData("bs.modal");
    })
</script>